#! /bin/sh

name=llvm
version=20.1.3
revision=1
tarball_url="https://github.com/llvm/llvm-project/releases/download/llvmorg-${version}/llvm-project-${version}.src.tar.xz"
tarball_blake2b="c738abb66dc82580a8f511829bcf87dd8deb8381bd073cd547e4eb02097c0190fa06488e5500cefce95953315432ee6ae3c103c491d08eca4b019e043691fc12"
imagedeps="build-essential cmake ninja-build git"
hostdeps="gcc pkg-config"
deps="core-libs ncurses zlib zstd libffi"

configure() {
        cmake_source_dir="${source_dir}/llvm" \
    cmake_configure \
        -UBUILD_SHARED_LIBS \
        -UENABLE_STATIC \
        -DLLVM_LINK_LLVM_DYLIB=ON \
        -DLLVM_ENABLE_FFI=ON \
        -DLLVM_ENABLE_EH=ON \
        -DLLVM_ENABLE_RTTI=ON \
        -DLLVM_ENABLE_PROJECTS="clang;lld" \
        -DLLVM_DEFAULT_TARGET_TRIPLE=${OS_TRIPLET} \
        -DLLVM_HOST_TRIPLE=${OS_TRIPLET} \
        -Wno-dev
}

build() {
    ninja -j${parallelism}
}

package() {
    DESTDIR="${dest_dir}" ninja install

    rm -rf "${dest_dir}${prefix}"/lib/*.a

    post_package_strip
}
